home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / OUTPUT / STYLE.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  19.6 KB  |  490 lines

  1. package sub_arctic.output;
  2.  
  3.  
  4. import sub_arctic.input.*;
  5.  
  6. import java.awt.Font;
  7. import java.awt.Dimension;
  8. import java.util.Vector;
  9.  
  10. /**
  11.  * This is an abstract class for generating the styles for a 
  12.  * particular look and giving the toolkit information about
  13.  * the feel.
  14.  * 
  15.  * @author Ian Smith
  16.  */
  17.  
  18. public abstract class style {
  19.  
  20.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  21.  
  22.   /* ****************** VERTICAL SCROLLBAR ***************/
  23.   /**
  24.    * Construct three images for a vertical scrollbar. Vertical scrollbars
  25.    * in sub_arctic are assumed to be of fixed width (although this
  26.    * is really not true for motif). All three of these images 
  27.    * must be of the same width. Image #0 is the up image, 
  28.    * image #1 is the down image and #2 is the background image (which will
  29.    * get tiled along the length of the scrollbar).
  30.    * 
  31.    * @return loaded_image[] an array of 3 images for displaying a scrollbar 
  32.    *                        in your style.
  33.    */
  34.   public abstract loaded_image[] v_scrollbar_images();
  35.  
  36.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  37.  
  38.   /**
  39.    * This method should return how far from the left edge the scrollbar
  40.    * is placed in this style. 
  41.    * @return int the "shift" of the v_scrollbar thumb to the right.
  42.    */
  43.   public abstract int v_scrollbar_thumb_shift();
  44.  
  45.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  46.  
  47.   /**
  48.    * This method should return an image of a thumb of a given
  49.    * height. 
  50.    * @param int h the height of the thumb in pixels.
  51.    */
  52.   public abstract loaded_image v_scrollbar_thumb(int h);
  53.  
  54.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  55.  
  56.   /**
  57.    * This is the minimum height of a scrollbar thumb. 
  58.    * @return the minimum usable size of a scrollbar thumb (in pixels).
  59.    */
  60.   public abstract int v_scrollbar_minimum_thumb_size();
  61.  
  62.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  63.  
  64.   /* ****************** HORIZONTAL SCROLLBAR ***************/
  65.   /**
  66.    * Construct three images for a horizontal scrollbar. Horizontal scrollbars
  67.    * in sub_arctic are assumed to be of fixed height (although this
  68.    * is really not true for motif). All three of these images 
  69.    * must be of the same height. Image #0 is the left image, 
  70.    * image #1 is the right image and #2 is the background image (which will
  71.    * get tiled along the length of the scrollbar).
  72.    * 
  73.    * @return loaded_image[] an array of 2 images for displaying a scrollbar in 
  74.    *                        your style.
  75.    */
  76.   public abstract loaded_image[] h_scrollbar_images();
  77.  
  78.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  79.  
  80.   /**
  81.    * This method should return how far from the top edge the scrollbar
  82.    * is placed in this style. 
  83.    * @return int the "shift" of the h_scrollbar thumb down.
  84.    */
  85.   public abstract int h_scrollbar_thumb_shift();
  86.  
  87.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  88.  
  89.   /**
  90.    * This method should return an image of a thumb of a given
  91.    * width.
  92.    * @param int w the width of the thumb in pixels.
  93.    */
  94.   public abstract loaded_image h_scrollbar_thumb(int w);
  95.  
  96.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  97.  
  98.   /**
  99.    * This is the minimum width of a scrollbar thumb. 
  100.    * @return the minimum usable size of a scrollbar thumb (in pixels).
  101.    */
  102.   public abstract int h_scrollbar_minimum_thumb_size();
  103.  
  104.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  105.  
  106.   /* ****************** BUTTON ***************/
  107.   /**
  108.    * Construct the images for a button. In the returned array, 
  109.    * img 0 is the up and img 1 is the depressed (unhappy) appearance.
  110.    *
  111.    * @param String  label     the string for the button.
  112.    * @param Font    the font  to draw the button with.
  113.    * @param int     x_spacing the amount of x border (appears on left and 
  114.    *                          right).
  115.    * @param int     y_spacing the amount of y border (appears on top and 
  116.    *                          bottom).
  117.    * @param boolean menu true if you want the appearance of a menu button.
  118.    * @return loaded_image[] the resulting pair of images.
  119.    */
  120.   public abstract loaded_image[] button_make_images(String label,
  121.                             Font font,
  122.                             int x_spacing,
  123.                             int y_spacing,
  124.                             boolean menu);  
  125.  
  126.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  127.  
  128.   /**
  129.    * Construct the images for a button which is blank (so the app
  130.    * can draw on it). 
  131.    *
  132.    * @param int     width     this is the <I>usable</I> width you desire for 
  133.    *                          this button.
  134.    * @param int     height    this is the <I>usable</I> height you desire for 
  135.    *                          this button.
  136.    * @param int     x_spacing the amount of x border (appears on left and 
  137.    *                          right).
  138.    * @param int     y_spacing the amount of y border (appears on top and 
  139.    *                          bottom).
  140.    * @param boolean menu true if you want the appearance of a menu button.
  141.    * @return loaded_image[] the resulting pair of images.
  142.    */
  143.   public abstract loaded_image[] button_make_images(int width,
  144.                             int height,
  145.                             int x_spacing,
  146.                             int y_spacing,
  147.                             boolean menu);
  148.  
  149.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  150.  
  151.   /**
  152.    * Return the amount of shift in x required for an image to placed
  153.    * on this style of button. This does NOT including the x spacing
  154.    * but rather only the pixels that the button code isn't normally
  155.    * allowed to use (the beveling).
  156.    *
  157.    * @return int the amount to shift the image on a button in x.
  158.    */
  159.   public abstract int button_x_shift();
  160.  
  161.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  162.  
  163.   /**
  164.    * Return the amount of shift in y required for an image to placed
  165.    * on this style of button. This does NOT including the y spacing
  166.    * but rather only the pixels that the button code isn't normally
  167.    * allowed to use (the beveling).
  168.    *
  169.    * @return int the amount to shift the image on a button in y.
  170.    */
  171.   public abstract int button_y_shift();
  172.  
  173.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  174.  
  175.   /* ****************** RADIOBUTTON ***************/
  176.   /**
  177.    * Return a pair of images which give the off (img[0]) and the
  178.    * on (img[1]) appearance for a radio button. Note: For some styles, 
  179.    * this is the same appearance as a checkbox. These images should 
  180.    * be the same size.
  181.    * 
  182.    * @return loaded_image[] an array of 2 images for the off and on look of 
  183.    *                        a radio button.
  184.    */
  185.   public abstract loaded_image[] radio_button_make_images();
  186.  
  187.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  188.  
  189.   /**
  190.    * Return a pair of transitions images for the transitions from
  191.    * (img[0]) off to on and (img[1])on to off. A style may return
  192.    * null here there will be no special transition used. 
  193.    *
  194.    * @return loaded_image[] the resulting pair of images.
  195.    */
  196.   public abstract loaded_image[] radio_button_make_transitions();
  197.  
  198.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  199.  
  200.   /* ****************** CHECKBOX ***************/
  201.   /**
  202.    * Return a pair of images which give the off (img[0]) and the
  203.    * on (img[1]) appearance for a checkbox. Note: For some styles, 
  204.    * this is the same appearance as a radiobutton. These images should
  205.    * be the same size.
  206.    * 
  207.    * @return loaded_image[] an array of 2 images for the off and on look of 
  208.    *                        a checkbox.
  209.    */
  210.   public abstract loaded_image[] checkbox_make_images();
  211.  
  212.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  213.  
  214.   /**
  215.    * Return a pair of transition images for the transitions from
  216.    * (img[0]) off to on and (img[1])on to off. A style may return
  217.    * null here there will be no special transition used. 
  218.    *
  219.    * @return loaded_image[] resulting pair of transition images or null if no
  220.    *                        special transition effect is needed.
  221.    */
  222.   public abstract loaded_image[] checkbox_make_transitions();
  223.  
  224.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  225.  
  226.   /* ************************  SCALE  ***********************/
  227.   /**
  228.    * This function returns the image of a scale's background
  229.    * at a given width in pixels.
  230.    *
  231.    * @param int w the width of the scale in pixels.
  232.    * @return loaded_image the image of the scale's background.
  233.    */
  234.   public abstract loaded_image scale_background(int w);
  235.  
  236.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  237.  
  238.   /**
  239.    * This returns the height of the scale in pixels. We assume
  240.    * that scales are not resizable in height.
  241.    * @return int the height of the scale.
  242.    */
  243.   public abstract int scale_height();
  244.  
  245.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  246.  
  247.   /**
  248.    * This returns the image of the thumb of a scale.
  249.    * @return loaded_image the image of the thumb.
  250.    */
  251.   public abstract loaded_image scale_thumb();
  252.  
  253.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  254.  
  255.   /**
  256.    * This returns the number of pixels the thumb is shifted
  257.    * down from the top of the scale.
  258.    * @return int the amount of the shift of the thumb in y.
  259.    */
  260.   public abstract int scale_thumb_shift();
  261.  
  262.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  263.  
  264.   /**
  265.    * This returns the amount of space on both ends which 
  266.    * is used by the system for its beveling/color scheme.
  267.    * If you are using a 1 pixel bevel return 1 here.
  268.    *
  269.    * @return int the number of pixels to shift the display of the thumb to 
  270.    *             the right.
  271.    */
  272.   public abstract int scale_unusable_width();
  273.  
  274.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  275.  
  276.   /* **********************  MISC *************************/
  277.   /** 
  278.    * This function gets called to inform the style that the
  279.    * default_color_scheme has changed. This is to allow the
  280.    * style to do any necessary recalculation of images based
  281.    * on the new color_scheme before interactors become notified
  282.    * that there is a new color_scheme.
  283.    */
  284.   public abstract void color_scheme_changed();
  285.  
  286.   /* ************************   MENU   ***********************/
  287.   /**
  288.    * This function determines if a menu pops to the right and
  289.    * down from an menu button interactor or if it pops directly
  290.    * down. Return true for the (mac style) pop to the right
  291.    * type and false for the (motif style) pop string down type.
  292.    * @return boolean true for pop-right false for pop-down.
  293.    */
  294.   public abstract boolean menu_pop_right();
  295.  
  296.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  297.  
  298.   /**
  299.    * This function determines the "natural" size of menu item
  300.    * of text. Menu items can be made any width, but this expresses
  301.    * the natural size of the object. The style object may include
  302.    * extra space for interactors that are placed on the menu
  303.    * item.
  304.    * 
  305.    * @param String s         the string to display
  306.    * @param Font   f         the font to display the text in 
  307.    * @param int    x_spacing the amount of horizontal spacing desired  (this 
  308.    *                         is 1/2 the total horizontal spacing).
  309.    * @param int    y_spacing the amount of vertical spacing desired  (this 
  310.    *                         is 1/2 the total vertical spacing).
  311.    * @return Dimension the natural size of this menu item.
  312.    */
  313.   public abstract Dimension menu_item_natural_size(String s, Font f, 
  314.                            int x_spacing, 
  315.                            int y_spacing);
  316.  
  317.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  318.  
  319.   /**
  320.    * This function creates the two images of a menu up (unhighlighted)
  321.    * & down (highlighted). You must supply the width and height of
  322.    * the images you wish to create; use menu_item_natural_size()
  323.    * to determine the natural size of menu items.  The style
  324.    * object is expected to observe the x_spacing and y_spacing 
  325.    * arguments, even if this forces clipping or overdrawing 
  326.    * to occur.
  327.    *
  328.    * @param String  s         the string to display.
  329.    * @param Font    f         the font to display the text in.
  330.    * @param int     x_spacing the amount of horizontal spacing desired.
  331.    * @param int     y_spacing the amount of vertical spacing desired. 
  332.    * @param int     w         width of the image.
  333.    * @param int     h         height of the image.
  334.    * @param boolean pullright true if you want a notation for a pullright 
  335.    *                          image on this menu item.
  336.    */
  337.   public abstract loaded_image[] menu_item_image(String s, Font f,
  338.                          int x_spacing, int y_spacing,
  339.                          int w, int h,
  340.                          boolean pullright);
  341.  
  342.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  343.  
  344.   /**
  345.    * Return the image of a menu separator. The style may choose
  346.    * to return a zero height object for this separator if it does
  347.    * not allow menu separators.
  348.    *
  349.    * @return loaded_image the image of the separator.
  350.    */
  351.   public abstract loaded_image menu_item_separator(int w);
  352.  
  353.  
  354.   /* ************************ DRAWABLE ***********************/
  355.   /**
  356.    * This function gets called to force the style to set up
  357.    * a rectangular area of a drawable. The caller is requesting 
  358.    * that the drawable be prepared for further drawing by caller. 
  359.    * This is useful interactors which do their drawing in 
  360.    * draw_self_local() and/or people wishing to implement new
  361.    * interactors which can "fit in" with the style. 
  362.    * 
  363.    * @param drawable d    the drawable to prepare. 
  364.    * @param int      x    the x coordinate of the top left corner of the area to
  365.    *                      prepare.
  366.    * @param int      y    the y coordinate of the top left corner of the area to
  367.    *                      prepare.
  368.    * @param int      w    the width of the area to prepare.
  369.    * @param int      h    the height of the area of prepare.
  370.    * @param boolean  up   if this is true the style may draw this area raised, 
  371.    *                      if this is false the style may draw this area lowered.
  372.    *                      The style is under no obligation to follow this hint.
  373.    * @param boolean  fill true if the style system should fill the background
  374.    */
  375.   public abstract void drawable_prepare_rect(drawable d, int x, int y, 
  376.                          int w, int h, boolean up,
  377.                          boolean fill);
  378.  
  379.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  380.  
  381.   /**
  382.    * This function is called to allow the caller to determine what area
  383.    * of the drawable has been prepared by the style.
  384.    * @return int the amount of horizontal space used by the style (XXX 
  385.    *             assumes left/right symmetry)
  386.    */
  387.   public abstract int drawable_horizontal_space();
  388.  
  389.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  390.  
  391.   /**
  392.    * This function is called to allow the caller to determine what area
  393.    * of the drawable has been prepared by the style.
  394.    * @return int the amount of vertical space used by the style (XXX assumes 
  395.    *             up/down symmetry)
  396.    */
  397.   public abstract int drawable_vertical_space();
  398.  
  399.   /* ************************ MENUBAR ***********************/
  400.   /**
  401.    * This is the most complex of the style functions, and the one that
  402.    * certainly leaves the most room for improvement. The caller of 
  403.    * this function is requesting several things. First, an image to
  404.    * display for a menu bar of a given width. Second, a set of 
  405.    * rectangles that tell the menubar infrastructure what regions of
  406.    * the menu bar are "hot."  Finally, the caller is asking for
  407.    * a set of images that corresponds to the "depressed" images 
  408.    * of each hotspt.  <P>
  409.  
  410.    * The caller supplies the style system with two vectors. Each
  411.    * vector must contain <I>only</I> strings or loaded_images. (If
  412.    * the loaded images are taller than the height of the font supplied,
  413.    * they will be clipped.) The caller is responsible for making
  414.    * sure the types of the objects are correct. The style system will
  415.    * create it set of hot spots and images with the first vector
  416.    * occupying the "normal" or left positions and the the second
  417.    * vector occupying the "special" or right positions. These vectors
  418.    * may not be null, although they may be empty.
  419.    *
  420.    * @param Vector left_items     this should be a non-null (but possibly 
  421.    *                              empty) vector of strings and images. Items 
  422.    *                              in this vector will be replaced with 
  423.    *                              loaded_images representing that items "down" 
  424.    *                              image. These items will appear on the left 
  425.    *                              of the menu bar, in the order supplied.
  426.    * @param Vector right_items    this should be a non-null (but possibly 
  427.    *                              empty) vector of strings and images. Items 
  428.    *                              in this vector will be replaced with 
  429.    *                              loaded_images representing that items "down" 
  430.    *                              image. These items will appear on the right 
  431.    *                              of the menubar in the order supplied (last 
  432.    *                              in the Vector being the rightmost).
  433.    * @param int    width          width of the menubar in pixels (items which 
  434.    *                              don't fit on the menubar will be clipped).
  435.    * @param Font   font           the font to use for rendering strings. If 
  436.    *                              you have a menubar which has only images on 
  437.    *                              it, the menu bar is still the height of this 
  438.    *                              font.
  439.    * @param Vector left_hotspots  the caller should pass a non-null but empty 
  440.    *                              vector which will be filled in which 
  441.    *                              Rectangle objects indicating the positions 
  442.    *                              of the objects in the left vector on the 
  443.    *                              returned image.
  444.    * @param Vector right_hotspots the caller should pass a non-null but empty 
  445.    *                              vector which will be filled in which 
  446.    *                              Rectangle objects indicating the positions 
  447.    *                              of the objects in the right vector on the 
  448.    *                              returned image.
  449.    * @return loaded_image the image of the menu bar at the selected width.
  450.    */
  451.   public abstract loaded_image make_menubar_images(Vector left,
  452.                            Vector right,
  453.                            int width,
  454.                            Font font,
  455.                            Vector left_hotspots,
  456.                            Vector right_hotspots);
  457.  
  458.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  459.  
  460.   /**
  461.    * This parameter controls how far down the images resulting from
  462.    * a menubar should be shifted down (in their hotspot) to compensate
  463.    * for potential style system beveling.
  464.    *
  465.    * @return int the number of pixels the depressed images should be shifted 
  466.    *             down in their hotspot when the button is depressed.
  467.    */
  468.   public abstract int menubar_image_shift();
  469.  
  470.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  471.  
  472. }
  473.  
  474. /*=========================== COPYRIGHT NOTICE ===========================
  475.  
  476. This file is part of the subArctic user interface toolkit.
  477.  
  478. Copyright (c) 1996 Scott Hudson and Ian Smith
  479. All rights reserved.
  480.  
  481. The subArctic system is freely available for most uses under the terms
  482. and conditions described in 
  483.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  484. and appearing in full in the lib/interactor.java source file.
  485.  
  486. The current release and additional information about this software can be 
  487. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  488.  
  489. ========================================================================*/
  490.